<?PHP
	require 'config.php';
	require 'modifyImage.php';
	require 'CyrillicEncoder.php';
	
	//connecting to DB
	$vLink = mysql_connect($DBServer, $DBUser, $DBPassword);
	if(!$vLink) 
		die(mysql_error());
	
	//setting session encoding
	mysql_select_db($DBName, $vLink);	
	mysql_query("SET NAMES 'cp1251';", $vLink);
	mysql_query("SET CHARACTER SET 'cp1251';", $vLink);
	mysql_query("SET SESSION collation_connection = 'cp1251_general_ci';", $vLink);
	
	//retrieving params	
	$OwnerID = ReadInt($_GET['owner_id']);
	$OwnerType = ReadInt($_GET['owner_type']);
	$Order = ReadInt($_GET['order']);
	$Description = mysql_real_escape_string($_GET['description']);
	
	//sending query
	$vQuery = "INSERT INTO dikar2011_photos(id_obj, owner, ord, description) VALUES ('$OwnerID' , '$OwnerType', '$Order', '$Description')";
	mysql_query($vQuery);	

	function ReadInt($Param)
	{
		$vResult = -1;
		if(isset($Param))
		{
			$vResult = intval($Param);
		}
		return $vResult;
	}
		
	$vResult = mysql_insert_id();
	mysql_close($vLink);
	//printing update result for AS side
	echo $vResult;
?>